home *** CD-ROM | disk | FTP | other *** search
- unit Drwsutl1;
-
- interface
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ShellAPI, FileCtrl;
-
- function ShellExec(const PathStr, CmdStr, DirStr: string;
- PrintIt: boolean; Show: word; Wait: boolean): boolean;
- implementation
-
- { This function is from Delphi How To Copyright 1995 Waite Group Press }
- function ShellExec(const PathStr, CmdStr, DirStr: string;
- PrintIt: boolean; Show: word; Wait: boolean): boolean;
- var
- Inst: THandle;
- Path, CmdLine, Dir: PChar;
- Op: array[0..5] of Char;
- begin
- if PrintIt then StrPCopy(Op, 'print') else StrPCopy(Op, 'open');
- { Get memory for PChars }
- GetMem(Path, Length(PathStr)+1);
- GetMem(CmdLine, Length(CmdStr)+1);
- GetMem(Dir, Length(DirStr)+1);
- try
- { Copy strings to PChars }
- StrPCopy(Path, PathStr);
- StrPCopy(CmdLine, CmdStr);
- StrPCopy(Dir, DirStr);
- { Execute file }
- Inst := ShellExecute(0, Op, Path, CmdLine, Dir, Show);
- { If 32 or less, an error occurred }
- if Inst <= 32 then Result := False else Result := True;
- finally
- { Ensure memory is freed }
- FreeMem(Path, Length(PathStr)+1);
- FreeMem(CmdLine, Length(CmdStr)+1);
- FreeMem(Dir, Length(DirStr)+1);
- end;
- end;
-
-
- end.
-